package cn.ctbu.xiaopeng.studentscoremanage.utils;


import cn.ctbu.xiaopeng.studentscoremanage.enums.ResultEnum;
import cn.ctbu.xiaopeng.studentscoremanage.vo.PageResult;
import cn.ctbu.xiaopeng.studentscoremanage.vo.Result;

/**
 * @author xiaopeng
 * @version 1.0
 */
public class PageResultUtils {

    public static PageResult success(Object data , Long count) {
        PageResult result = new PageResult();
        result.setCode(0); //和layui 分页查询的成功响应码对应
        result.setData(data);
        result.setCount(count);
        result.setMsg("成功");
        return result;
    }

    public static PageResult success() {
        return success(null,null);
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
}
